package com.neuedu.myweather;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

/**
 * Hadoop工具类
 *
 * @author dell
 */
public class HadoopUtils {
    private static Configuration conf;
    private static FileSystem fs;

    static {
        init();
    }

    public static void init() {
        try {
            conf = new Configuration();
            conf.set("fs.defaultFs", "hdfs://master:9000");
            fs = FileSystem.get(conf);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void delete(Path path) {
        try {
            fs.delete(path, true);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static Configuration getConf() {
        return conf;
    }

    public static FileSystem getFs() {
        return fs;
    }
}
